package com.cherish.demo.service.impl;

import com.cherish.demo.config.caching.CacheNames;
import com.cherish.demo.db.entity.Test;
import com.cherish.demo.db.mapper.TestMapper;
import com.cherish.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @Classname TestServiceImpl
 * @Date 2020/6/28 0:01
 * @Created by admin
 * @Description TODO
 */
@Service
@CacheConfig(cacheNames = "TestSimpleServiceImpl")
public class TestSimpleServiceImpl implements TestService {

    @Autowired
    private TestMapper testMapper;

    @Override
    public int insert(Test test) {
        return testMapper.insert(test);
    }

    @Override
    public int updateById(Test test) {
        return testMapper.updateById(test);
    }

    @Cacheable(key = "#id", cacheManager = "cacheManagerJson", cacheNames = CacheNames.CACHE_30_S)
    @Override
    public Test selectById(long id) {
        return testMapper.selectById(id);
    }


}
